﻿using Microsoft.AspNetCore.Mvc;

namespace GrpcClientDemo.Controllers
{
    [ApiController]
    [Route("[controller]/[action]")]
    public class OrderController : ControllerBase
    {
        readonly Order.OrderClient orderClient;
        public OrderController(Order.OrderClient orderClient) 
        {
            this.orderClient = orderClient;
        }

        [HttpGet(Name = "CreateOrder")]
        public CreateResult CreateOrder() 
        {
            return orderClient.CreateOrder(new CreateRequest 
            {
                OrderNo = DateTime.Now.ToString("yyyyMMddHHmmss"),
                OrderName = "订单名称",
                Price = "12.32"
            });
        }

        [HttpGet(Name = "QueryOrder")]
        public QueryResult QueryOrder(int id) 
        {
            return orderClient.QueryOrder(new QueryRequest
            {
                Id = id,
            });
        }
    }
}
